<template>
	<view>
		<view class=""
			style="margin:5px;padding: 10px;border-radius: 20px;border: 1px solid;background-color: #ededed;box-sizing: border-box;">
			<view class="" style="display: flex;">
				<p>名称：</p>
				<p>{{userObj.nickName}}</p>
			</view>
			<view class="" style="display: flex;">
				<p>手机号：</p>
				<p>{{userObj.phone?userObj.phone:"暂无"}}</p>
			</view>
			<view class="" style="display: flex;">
				<p>id：</p>
				<p>{{userObj._id?userObj._id:"暂无"}}</p>
			</view>
		</view>
		<view class="" @click="scanCode">
			scancode
		</view>
		<view class="">
			<button style="width: 85%;background-color: #3998d8;color: white;" @click="jumpAddOrder()">截图上传单据</button>
		</view>
		<view class="" style="display: flex;margin: 5px;flex-direction: column;gap: 10px;">
			<view v-for="(v,k) in orderList"
				style="border-radius: 20px;padding: 10px;box-sizing: border-box;background-color: #ededed;width: 100%;display: flex;flex-direction: column;gap: 10px;">
				<view class="" style="display: flex;width: 100%;align-items: center;">
					<p style="line-height: 1;">消费方:{{v.name}}</p>
				</view>
				<view class="" style="display: flex;width: 100%;align-items: center;">
					<p style="line-height: 1;">消费金额:{{v.price}}</p>
				</view>
				<view class="" style="display: flex;width: 100%;align-items: center;">
					<p style="line-height: 1;">消费状态:{{v.status}}</p>
				</view>
				<view class="" style="display: flex;width: 100%;align-items: center;">
					<p style="line-height: 1;">消费类型:{{v.type}}</p>
				</view>
				<view class="" style="display: flex;width: 100%;align-items: center;">
					<p style="line-height: 1;">备注:{{v.remark}}</p>
				</view>
				<view class="" style="display: flex;width: 100%;align-items: center;">
					<p style="line-height: 1;">消费时间:{{v.time}}</p>
				</view>
				<view class="" style="display: flex;width: 100%;align-items: center;">
					<p style="line-height: 1;">订单号:{{v.orderCode}}</p>
				</view>
				<view class="" class="imgsContainerStyle" v-if="v.pic.length">
					<img v-for="(v1,k1) in v.pic" :key="k1" :src="v1.src" alt=""
						style="width: 100%;height: 100%;object-fit: cover;">
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userObj: uni.getStorageSync('userObj'),
				orderList: []
			}
		},
		methods: {
			jumpAddOrder() {
				uni.redirectTo({
					url: '/pages/index/index'
				})
			},
			scanCode() {
				let that = this
				uni.scanCode({
					onlyFromCamera: true,
					success(res) {
						console.log(res);
						that.payment()
					}
				})
			},
			payment() {
				uni.requestPayment({
					provider: 'wxpay',
					orderInfo: 'ads',
					success(res) {
						console.log(res);
					}
				})
			}
		},
		onShow() {
			let that = this
			uniCloud.callFunction({
				name: "getAllOrderByDate",
				data: {
					userid: that.userObj._id,
					// date:
				},
				success(res) {
					that.orderList = res.result.data
				}
			})
		}
	}
</script>

<style>
	.imgsContainerStyle {
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(30vw, 1fr));
		grid-template-rows: repeat(1, minmax(30vw, 1fr));
		gap: 10px;
		max-width: 90vw;
		margin: 0 auto;
	}
</style>